# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgname=python-mitmproxy-rs
_pyname=mitmproxy_rs
pkgver=0.4.0
pkgrel=1
pkgdesc="Python bindings for mitmproxy's Rust code"
arch=('loong64' 'x86_64')
url='https://github.com/mitmproxy/mitmproxy_rs'
license=('MIT')
depends=('python')
makedepends=('maturin' 'python-installer' 'cargo')
options=(!lto)
source=("https://github.com/mitmproxy/mitmproxy_rs/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha256sums=('1eb33d77c1da48911f1bb365beb34ef2eb235683a737ebaeddcf055854d5d673')
b2sums=('4f1aa5c52bfc5f3104b7d7dcbebbccf030d0c489d4bc9b38170a494cfdec8ee8c704e2fc7df422cc50736db3cc0c9e26aee2dfdb4ca1247990bdbc0e938f0ed4')

build() {
  cd ${_pyname}-${pkgver}/mitmproxy-rs
  maturin build --release --strip
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd ${_pyname}-${pkgver}
  python -m installer --destdir=test_dir target/wheels/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  python -c 'import mitmproxy_rs'
}

package() {
  cd ${_pyname}-${pkgver}
  python -m installer --destdir="$pkgdir" target/wheels/*.whl
  install -Dm0644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

# vim: ts=2 sw=2 et:
